#ifndef CURLTOOL_H
#define CURLTOOL_H

#include <string>
#include <stdio.h>
#include <curl/curl.h>
#include <exception>
#include <stdexcept>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#include <string.h>
#include <stdarg.h>

using namespace std;

class LibCURL
{
        static bool m_global_init;
    public:
        static int Init();
        static int Fini();
};

class CurlTool
{
        static size_t WriteFileFunc(void *buffer, size_t size, size_t nmemb, void *stream);
        static size_t ReadFileFunc(void *ptr, size_t size, size_t nmemb, void *stream);
        static size_t DoNothingWrite(char *ptr, size_t size, size_t nmemb, void *userdata);
    public:
        CurlTool(string ftp_ip, string ftp_port, string ftp_user, string ftp_passwd);
        int DownloadFile(string ftp_file, string local_file);
        int UploadFile(string ftp_file, string local_file);
        int DeleteFile(string ftp_file);
        ~CurlTool();
    private:
        string m_ftp_ip;
        string m_ftp_port;
        string m_ftp_user;
        string m_ftp_passwd;
        char m_ftp_error[256];
};

#endif // CURLTOOL_H
